package com.ycf.demo1;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;

public class MyActivity extends AppCompatActivity {

    String qq;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_layout);

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            qq = bundle.getString("qq");//获取qq账号
        }
        System.out.println("thund   qq = " + qq);
        ImageView imageView = findViewById(R.id.imagetouxiang);
        System.out.println("qq = " + qq);
        String imageUrl = "http://q1.qlogo.cn/g?b=qq&nk="+qq+"&s=100";//网络图片的地址

        System.out.println("imageUrl = " + imageUrl);
        Glide.with(MyActivity.this).load(imageUrl).into(imageView);
        Glide.with(getBaseContext())
                .load(imageUrl)
                .listener(new RequestListener<Drawable>() {
                    @Override
                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                        System.out.println("图片加载失败");
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                        System.out.println("图片加载成功");
                        return false;
                    }
                }).into(imageView);




    }

}
